using System;
using System.IO;
using System.Reflection;
using System.Text;

namespace Lookstone.Configuration
{
	/// <summary>
	/// This is a static class that will store the global application settings.
	/// The application will automatically load and save this object when 
	/// starting and ending execution.
	/// </summary>
	public sealed class AppSettings
	{
		public static Settings Settings
		{
			get
			{
				if (m_appSettings == null)
				{
					Assembly assembly = Assembly.GetEntryAssembly();
					string path = Path.Combine(Lookstone.IO.Directory.GetAppDataPath(), Path.GetFileNameWithoutExtension(assembly.Location) + ".settings.xml");

					m_appSettings = new Settings("UserAppSettings", path);
				}

				return m_appSettings;
			}
		}

		public static void Save()
		{
			if (m_appSettings != null)
				m_appSettings.Save();
		}

		static private Settings m_appSettings;
	}
}
